package com.yxinsur.imc.web.controller.business;

import com.yxinsur.imc.business.form.OrderEndorseForm;
import com.yxinsur.imc.business.service.IImcOrderBankInfoEndorseService;
import com.yxinsur.imc.business.service.IImcOrderEndorseService;
import com.yxinsur.imc.business.service.IImcOrderPersonEndorseService;
import com.yxinsur.imc.business.service.IImcOrderRiskEndorseService;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 批单Controller
 *
 * @author imc
 * @date 2021-10-09
 */
@RestController
@Api(value = "批单模快接口", tags = "2.3批单模快接口")
@RequestMapping("/business/endorse")
public class ImcOrderEndorseController extends BaseController {


    private final IImcOrderEndorseService imcOrderEndorseService;
    private final IImcOrderRiskEndorseService imcOrderRiskEndorseService;
    private final IImcOrderPersonEndorseService imcOrderPersonEndorseService;
    private final IImcOrderBankInfoEndorseService imcOrderBankInfoEndorseService;

    public ImcOrderEndorseController(IImcOrderEndorseService imcOrderEndorseService, IImcOrderRiskEndorseService imcOrderRiskEndorseService,
                                     IImcOrderPersonEndorseService imcOrderPersonEndorseService, IImcOrderBankInfoEndorseService imcOrderBankInfoEndorseService) {
        this.imcOrderEndorseService = imcOrderEndorseService;
        this.imcOrderRiskEndorseService = imcOrderRiskEndorseService;
        this.imcOrderPersonEndorseService = imcOrderPersonEndorseService;
        this.imcOrderBankInfoEndorseService = imcOrderBankInfoEndorseService;
    }

    /**
     * 根据{保单ID}查询批单详情
     */
    @ApiOperation("根据{保单ID}查询批单详情")
    @GetMapping(value = "/get/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId) {
        return AjaxResult.success(this.imcOrderEndorseService.getOrderEndorseByOrderId(orderId));
    }

    /**
     * 新增保单险种批单
     *
     * @param form 保单险种批单
     * @return AjaxResult
     */
    @Log(title = "新增保单险种批单", businessType = BusinessType.INSERT)
    @ApiOperation("新增保单险种批单")
    @PostMapping("/risk/add")
    public AjaxResult riskAdd(@RequestBody OrderEndorseForm form) {
        return imcOrderRiskEndorseService.addImcOrderRiskEndorse(form);
    }

    /**
     * 新增保单人员批单
     */
    @Log(title = "新增保单人员批单", businessType = BusinessType.INSERT)
    @ApiOperation("新增保单人员批单")
    @PostMapping("/person/add")
    public AjaxResult personAdd(@RequestBody OrderEndorseForm form) {
        return this.imcOrderPersonEndorseService.addImcOrderPersonEndorse(form);
    }


    /**
     * 新增缴费信息批单
     */
    @Log(title = "新增缴费信息批单", businessType = BusinessType.INSERT)
    @ApiOperation("新增缴费信息批单")
    @PostMapping("/bankInfo/add")
    public AjaxResult bankInfoAdd(@RequestBody OrderEndorseForm form) {
        return this.imcOrderBankInfoEndorseService.addImcOrderBankInfoEndorse(form);
    }
}
